﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace HXH.Redis
{
    /// <summary>
    /// redis客户端
    /// </summary>
    public interface IRedisClient
    {
        /// <summary>
        /// 获取基有给定键的值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        byte[] Get(string key);
        /// <summary>
        /// 异步获取基有给定键的值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        Task<byte[]> GetAsync(string key);
        /// <summary>
        /// 删除具有给定键的值
        /// </summary>
        /// <param name="key"></param>
        bool Remove(string key);
        /// <summary>
        /// 异步删除具有给定键的值
        /// </summary>
        /// <param name="key"></param>
        Task<bool> RemoveAsync(string key);
        /// <summary>
        /// 设置具有给定键的值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="dateTime"></param>
        bool Set(string key, byte[] value, DateTime? expireTime = null);
        /// <summary>
        /// 异步设置具有给定键的值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="dateTime"></param>
        Task<bool> SetAsync(string key, byte[] value, DateTime? expireTime = null);

        #region 扩展方法
        bool Set<T>(string key, T message,DateTime? expireTime = null);
        Task<bool> SetAsync<T>(string key, T message, DateTime? expireTime = null);
        T Get<T>(string key);
        Task<T> GetAsync<T>(string key);
        /// <summary>
        /// 设置具有给定键的值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expireTime"></param>
        bool SetString(string key,string value,DateTime? expireTime = null);
        /// <summary>
        /// 设置具有给定键的值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expireTime"></param>
        Task<bool> SetStringAsync(string key, string value, DateTime? expireTime = null);
        /// <summary>
        /// 获取基有给定键的值
        /// </summary>
        /// <param name="key"></param>
        string GetString(string key);
        /// <summary>
        /// 异步获取基有给定键的值
        /// </summary>
        /// <param name="key"></param>
        Task<string> GetStringAsync(string key);
        #endregion
    }
}
